package com.wangzhou.tour.pojo;

import java.util.Date;

import com.alibaba.fastjson.JSONObject;
import com.wangzhou.common.util.DateUtil;

/**
 * 商品表的pjo 属性和表一模一样
 * 
 * @author zjx
 *
 */
public class AGoods
{
	private int id;
	private int createId;
	private int cateId;
	private int cityId;
	private String name;
	private String imgPath;
	private String brief;
	private String traffic;
	private String group;
	private Date endtime;
	private double marketPrice;
	private double price;
	private int viewCount;
	private byte status;
	private Date createtime;
	private Date updatetime;
	private Date pubtime;

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getCreateId()
	{
		return createId;
	}

	public void setCreateId(int createId)
	{
		this.createId = createId;
	}

	public int getCateId()
	{
		return cateId;
	}

	public void setCateId(int cateId)
	{
		this.cateId = cateId;
	}

	public int getCityId()
	{
		return cityId;
	}

	public void setCityId(int cityId)
	{
		this.cityId = cityId;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getImgPath()
	{
		return imgPath;
	}

	public void setImgPath(String imgPath)
	{
		this.imgPath = imgPath;
	}

	public String getBrief()
	{
		return brief;
	}

	public void setBrief(String brief)
	{
		this.brief = brief;
	}

	public String getTraffic()
	{
		return traffic;
	}

	public void setTraffic(String traffic)
	{
		this.traffic = traffic;
	}

	public String getGroup()
	{
		return group;
	}

	public void setGroup(String group)
	{
		this.group = group;
	}

	public Date getEndtime()
	{
		return endtime;
	}

	public void setEndtime(Date endtime)
	{
		this.endtime = endtime;
	}

	public double getMarketPrice()
	{
		return marketPrice;
	}

	public void setMarketPrice(double marketPrice)
	{
		this.marketPrice = marketPrice;
	}

	public double getPrice()
	{
		return price;
	}

	public void setPrice(double price)
	{
		this.price = price;
	}

	public int getViewCount()
	{
		return viewCount;
	}

	public void setViewCount(int viewCount)
	{
		this.viewCount = viewCount;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreatetime()
	{
		return createtime;
	}

	public void setCreatetime(Date createtime)
	{
		this.createtime = createtime;
	}

	public Date getUpdatetime()
	{
		return updatetime;
	}

	public void setUpdatetime(Date updatetime)
	{
		this.updatetime = updatetime;
	}

	public Date getPubtime()
	{
		return pubtime;
	}

	public void setPubtime(Date pubtime)
	{
		this.pubtime = pubtime;
	}

	@Override
	public String toString()
	{
		return "AGoods [id=" + id + ", createId=" + createId + ", cateId=" + cateId + ", cityId=" + cityId + ", name="
				+ name + ", imgPath=" + imgPath + ", brief=" + brief + ", traffic=" + traffic + ", group=" + group
				+ ", endtime=" + endtime + ", marketPrice=" + marketPrice + ", price=" + price + ", viewCount="
				+ viewCount + ", status=" + status + ", createtime=" + createtime + ", updatetime=" + updatetime
				+ ", pubtime=" + pubtime + "]";
	}
	
	/**
	 * 将pojo转换为json字符串
	 * @return
	 */
	public JSONObject toJSON()
	{
		DateUtil dateUtil = new DateUtil();
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("id", this.getId() + "");
		jsonObj.put("cateId", this.getCateId() + "");
		jsonObj.put("cityId", this.getCityId());
		jsonObj.put("name", this.getName());
		jsonObj.put("imgPath", this.getImgPath());
		jsonObj.put("brief", this.getBrief());
		jsonObj.put("traffic", this.getTraffic());
		jsonObj.put("group", this.getGroup());
		jsonObj.put("endtime", dateUtil.formatDateTime(this.getEndtime()));
		jsonObj.put("marketPrice", this.getMarketPrice() + "");
		jsonObj.put("price", this.getPrice() + "");
		/*
		 * 将字符串转换为整数或者double,只能使用以下两种方法
		 Integer.valueOf("");Double.valueOf("")
		Integer.parseInt("");Double.parseDouble("");*/
		jsonObj.put("viewCount", this.getViewCount() + "");
		jsonObj.put("status", this.getStatus());
		jsonObj.put("createtime", dateUtil.formatDateTime(this.getCreatetime()));
		jsonObj.put("updatetime", dateUtil.formatDateTime(this.getUpdatetime()));
		jsonObj.put("pubtime", dateUtil.formatDateTime(this.getPubtime()));
		return jsonObj; 
	}
}
